<?php

namespace Gxk3\Controller;


class CommonController extends CommonBaseController {
	public function __construct() {
		parent::__construct ();
		
		if(!$this->model_is_need_check()){//判定是否需要验证
// 			$this->check_user();
		}
	}
    
	
	function check_user(){
		$session_id = I("session_id");
		$user_info = S($session_id);
		if(!$user_info){
			$json_result['status_code']=101;//找不到用户
			$json_result['message']="未登陆或登陆失效";//找不到用户
			$json_result['result']='';
			echo json_encode($json_result,JSON_UNESCAPED_UNICODE);
			exit();
		}

		//判断这个id是否有效
		$user_session_id = S($user_info['id']);
		if($user_session_id!=$session_id){
			$json_result['status_code']=105;//用户session过期
			$json_result['message']="登陆已过期";//找不到用户
			$json_result['result']='';
			echo json_encode($json_result,JSON_UNESCAPED_UNICODE);
			exit();
		}
		
	}
	
	
	
    /**
     * 函数用途描述:判断模块名是否需要验证
     * @date: 2015-8-3
     * @author : Banyan
     * @param	:
     * @return :
     */
    function model_is_need_check() {
    	$arry = array (
    			"Gxk3","Userjson","Code","Danshuang","Daxiao","Dm","Wx","Index","User","Download","Codebm","Codebmjson",
    			"Agent",
    	);
    		$url = CONTROLLER_NAME;
    	if (in_array ( $url, $arry )) {
    		return true;
    	} else {
    		return false;
    	}
    }
    
	
	/* 进入系统前的过滤，如果返回false会进入错误页面 */
	protected function init_show() {
		/*
		 * $ctrl = strtolower ( CONTROLLER_NAME ); $ctrl_action = strtolower ( CONTROLLER_NAME . '-' . ACTION_NAME ); $arr = array ( 'index-index', 'user', 'wechat', ); if (! IS_AJAX) { //如果有get请求里面有设定的参数就可以 if($_GET['yun_filter'] != ''){ return true; } if (in_array ( $ctrl, $arr ) || in_array ( $ctrl_action, $arr )) { return true; } else { $this->redirect ( "Index/index" ); return false; } }
		 */
		return true;
	}
}